'use strict'

/**
 * 生产环境
 */

const os = require('os')
const path = require('path')

module.exports = app => {
  const config = {}

  config.sequelize = {
    username: 'root',
    password: '41142531@QQ',
    database: 'ws_admin',
    host: '172.27.0.11',
    port: 53306,
    dialect: 'mysql'
  }

  // 生产环境跨域配置
  config.cors = {
    origin: ''
  }

  // 启用多进程模式
  config.cluster = {
    enable: true, // 启用集群模式
    num: 2, // 集群数量
    https: { // 启用HTTPS支持
      key: path.join(__dirname, '../cert/_.yisbar.com.key'), // https 证书绝对目录
      cert: path.join(__dirname, '../cert/_.yisbar.com.crt') // https 证书绝对目录
    },
    listen: {
      isSecure: true
    }
  }

  // 自定义日志路径
  // https://eggjs.org/zh-cn/core/logger.html
  config.logger = {
    dir: `/usr/logs/${app.name}`,
    outputJSON: true,
    appLogName: `${app.name}-web.log`,
    coreLogName: 'egg-web.log',
    agentLogName: 'egg-agent.log',
    errorLogName: 'common-error.log'
  }

  return config
}
